<script>
import { findAll, add, update, deleteById, selectById } from "@/api/empin.js";

export default {

  methods: {
    async deleteById(id) {
      try {
        const confirmResult = await this.$confirm("确认删除?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        });

        if (confirmResult) {
          const result = await deleteById(id);
          if (result.data.code === 1) {
            this.$message({ message: "恭喜你，删除成功", type: "success" });
            await this.init(); // Re-fetch data after successful deletion
          } else {
            this.$message.error(result.data.msg);
          }
        }
      } catch (error) {
        this.$message({ type: "info", message: "已取消删除" });
      }
    },
    getEducationLabel(educationCode) {
      const educationMap = {
        "1": "高中",
        "2": "大专",
        "3": "本科",
        "4": "研究生",
        "5": "其他",
      };
      return educationMap[educationCode] || "未知";
    },
  },

},
</script>
